#include "junix.h"
#include <ext/hash_map>

using namespace std;
using __gnu_cxx::hash;

struct jhash {
	size_t operator()(const string& s) const {
		static hash<const char*> hasher;
		return hasher(s.c_str());
	}
};

int main(int argc, char **argv)
{
	typedef __gnu_cxx::hash_map<std::string,int,jhash> MAP;
	MAP words;
	std::ifstream file("BIGTXT");
	std::string line, word;
	std::stringstream fmt;
	std::clock_t begt = clock();

	while (getline(file, line)) {
		fmt<<line;
		while (!fmt.eof()) {
			fmt>>word;
			++ words[word];
		}

		fmt.clear();
	}

	std::clock_t endt = clock();
	std::cout<<endt-begt<<std::endl;

	/*
	BOOST_FOREACH(MAP::value_type& s, words) {
		std::cout<<"("<<s.first<<","
			<<s.second<<")"<<std::endl;
	}
	*/

	return 0;
}
